FROM apline/3.9
MAINTAINER hanye
ARG version='1.14.0'
ENV USER=www \
    version=${version}
RUN addgroup -g 499 -S ${USER} \
&& adduser -HDu 499 -s /sbin/nologin -g 'web server' -G ${USER}  ${USER}  \
&&  apk add --no-cache curl \
&&  apk add --no-cache --virtual .build-deps \
		gcc \
		libc-dev \
		make \
		openssl-dev \
		pcre-dev \
		zlib-dev \
		linux-headers \
		wget \
		gnupg \
		libxslt-dev \
		gd-dev \
		geoip \
		geoip-dev\
		gnupg \
&& cd /usr/local \
&& curl -sO http://nginx.org/download/nginx-${version}.tar.gz \
&& tar xf  nginx-${version}.tar.gz \
&& rm -rf  nginx-${version}.tar.gz \
WORKDIR /usr/local/nginx-${version}
RUN ./configure \
--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--user=${USER} \
--group=${USER} \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_flv_module \
--with-http_mp4_module \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
&& make && make install \
&&  mkdir -p /var/tmp/nginx/{client,fastcgi,proxy,uwsgi} \
&& echo "daemon off;" >> /etc/nginx/nginx.conf \
&& apk del wget \
&& rm -rf /usr/local/nginx-${version} \
&& rm -rf /var/cache/apk/* \
&& rm -rf /etc/nginx/nginx.conf
#COPY conf.tar.gz /etc/nginx/
#RUN cd /etc/nginx/ \
&& tar xf conf.tar.gz
COPY nginx.conf /etc/nginx/nginx.conf
ENV PATH /usr/local/nginx/sbin:$PATH
EXPOSE 80/tcp 443/tcp
ENTRYPOINT /usr/local/nginx/sbin/nginx
